package com.glsc.ngateway.common.api.flowable.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.flowable.resp.ResponseSituationDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Transient;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@AllArgsConstructor
@Builder
@NoArgsConstructor
@ToString
public class FlowFormEventDto implements Serializable {

    @ApiModelProperty(value = "流程ID")
    private String processId;

    @ApiModelProperty(value = "流程创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime processCreateTime;

    @ApiModelProperty(value = "事件发生时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate eventHappenTime;

    /**
     * 流程标题
     */
    @ApiModelProperty(value = "流程标题")
    String processTitle;

    /**
     * 事件标题
     */
    @ApiModelProperty(value = "事件标题")
    String eventTitle;


    /**
     * 发起人姓名
     */
    @ApiModelProperty(value = "发起人姓名")
    String flowCreateOperatorName;

    /**
     * 发起人账号oa
     */
    @ApiModelProperty(value = "发起人账号oa")
    String flowCreateOperatorAccount;

    @ApiModelProperty(value = "发起人部门名称")
    String flowCreatorDepartment;

    /**
     * 系统名称
     */
    @ApiModelProperty(value = "系统名称")
    private String systemName;

    /**
     * 系统代码
     */
    @ApiModelProperty(value = "系统代码")
    private String systemCode;

    /**
     * 系统管理员姓名
     */
    @ApiModelProperty(value = "系统管理员姓名")
    private String systemAdminName;


    /**
     *系统管理员账号oa
     */
    @ApiModelProperty(value = "系统管理员账号oa")
    private String systemAdminAccount;

    /**
     * 系统管理员姓名
     */
    @ApiModelProperty(value = "系统归属部门")
    private String systemBelongDepartment;

    @ApiModelProperty(value = "事件概述")
    private String eventSummary;

    @ApiModelProperty(value = "事件状态 字典")
    private String eventStatus;

    @ApiModelProperty(value = "事件分类 字典")
    private String eventClass;

    @ApiModelProperty(value = "事件分级 字典")
    private String eventGrade;

    @ApiModelProperty(value = "外部事件分类 字典")
    private String eventClassExternal;

    @ApiModelProperty(value = "外部事件分级 字典")
    private String eventGradeExternal;

    @ApiModelProperty(value = "事件结果 ")
    private String eventResult;

    @ApiModelProperty(value = "事件报告 暂时不需要，应该使用事件报告文件 ")
    private String eventReport;

    @ApiModelProperty(value = "事件报告文件")
    private String eventReportDocIdList;

    @ApiModelProperty(value = "事件报告文件")
    @Transient
    private List<AppendixDto> eventReportDocList;

    @Builder.Default
    @ApiModelProperty(value = "是否完成 ")
    private int isClose = 0;

    @ApiModelProperty(value = "事件成因")
    private Integer eventCause;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime insertTime;

    @ApiModelProperty(value = "更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime updateTime;


    /**
     *
     * TODO 暂时这样
     * * * * */
    public static FlowFormEventDto instance(ResponseSituationDto r) {
        return new FlowFormEventDto();
    }

    /**
     * 整改措施
     */
    @ApiModelProperty(value = "整改明细")
    List<FlowFormEventDetailImproveDto> detailImproves;
}
